package ec.atreasure.com.ui.refresh;

import android.support.v4.widget.SwipeRefreshLayout;

import ec.atreasure.com.core.app.Atreasure;

/**
 * Description :下拉刷新业务逻辑控制
 * Created by wangjin on 2019/7/11.
 * Job number：
 * Phone ：18301070822
 * Email： 120182051@qq.com
 * Person in charge : 汪渝栋
 * Leader：
 */
public class RefreshHandler implements SwipeRefreshLayout.OnRefreshListener {

    private SwipeRefreshLayout mSwipeRefreshLayout;

    public RefreshHandler(SwipeRefreshLayout mSwipeRefreshLayout) {
        this.mSwipeRefreshLayout = mSwipeRefreshLayout;
        this.mSwipeRefreshLayout.setOnRefreshListener(this);
    }

    @Override
    public void onRefresh() {
        refresh();
    }


    private void refresh() {
        mSwipeRefreshLayout.setRefreshing(true);
        Atreasure.getHandler().postDelayed(new Runnable() {
            @Override
            public void run() {
                mSwipeRefreshLayout.setRefreshing(false);
            }
        }, 2000);
    }
}
